package lang;

import lombok.*;

import java.util.Arrays;

/**
 * @classname:Student
 * @description:
 * @author: Mr.Z
 * @date: 2020/12/7 23:06
 * @version: 0.1
 * @since:1.8
 */
@Setter
@Getter
@AllArgsConstructor
@NoArgsConstructor
@ToString
public class Student implements Cloneable {
    private Integer id;// private final int value 不可变
    private String name;//private final char value[];不可变
    private String[] hobby;

    @Override
    protected Object clone() {
        Student student = null;
        try {
            student = (Student)super.clone();
            //方法一
//            student.setHobby(hobby.clone());
            //方法二
            student.setHobby(Arrays.copyOf(this.hobby,hobby.length));
        } catch (CloneNotSupportedException e) {
            e.printStackTrace();
        }
        return student;
    }
}
